﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace TestPictrueGenerator
{
    

    class BitmapGenerator
    {
        public int resX { set; get; }
        public int resY { set; get; }

        public BitmapGenerator(int x, int y)
        {
            this.resX = x;
            this.resY = y;
        }

        public Bitmap createFrameImage()
        {
            Bitmap bitmap = new Bitmap(resX, resY);
            var sourcegra = Graphics.FromImage(bitmap);//存入画布

            Pen whitePen = new Pen(Color.White, 1);
            //sourcegra.DrawString("Frame", new Font("宋体", 20, FontStyle.Regular), new SolidBrush(Color.White), 20, 100);//在画布绘制字体
            sourcegra.DrawLine(whitePen, 0, 0, bitmap.Width, 0);
            sourcegra.DrawLine(whitePen, 0, 0, 0, bitmap.Height);
            sourcegra.DrawLine(whitePen, 0, bitmap.Height -1 , bitmap.Width, bitmap.Height -1);
            sourcegra.DrawLine(whitePen, bitmap.Width -1, 0, bitmap.Width -1, bitmap.Height);
            return bitmap;
        }
        public Bitmap createColorImage(Color c)
        {
            Bitmap bitmap = new Bitmap(resX, resY);
            var sourcegra = Graphics.FromImage(bitmap);//存入画布

            sourcegra.Clear(c);
            return bitmap;
        }

        public Bitmap createScaleImage()
        {
            Bitmap bitmap = new Bitmap(resX, resY);
            Pen whitePen = new Pen(Color.White, 1);
            var sourcegra = Graphics.FromImage(bitmap);//存入画布

            for (int x = 0; x < bitmap.Width; x += 100)
            {
                sourcegra.DrawLine(whitePen, x, 0, x, 20);
                if (x != 0)
                    sourcegra.DrawString(x.ToString(), new Font("宋体", 16, FontStyle.Regular), new SolidBrush(Color.White), x, 30);
            }

            for (int x = 0; x < bitmap.Width; x += 10)
            {
                sourcegra.DrawLine(whitePen, x, 0, x, 10);
            }

            for (int y = 0; y < bitmap.Height; y += 100)
            {
                sourcegra.DrawLine(whitePen, 0, y, 20, y);
                if(y!= 0)
                    sourcegra.DrawString(y.ToString(), new Font("宋体", 16, FontStyle.Regular), new SolidBrush(Color.White), 30, y);
            }

            for (int y = 0; y < bitmap.Height; y += 10)
            {
                sourcegra.DrawLine(whitePen, 0, y, 10, y);
            }

            return bitmap;
        }

        public Bitmap createFrameTriangleImage()
        {
            Bitmap bitmap = new Bitmap(resX, resY);
            var sourcegra = Graphics.FromImage(bitmap);//存入画布

            sourcegra.Clear(Color.White);

            Pen whitePen = new Pen(Color.Black, 1);
            sourcegra.DrawLine(whitePen, 0, 0, bitmap.Width, 0);
            sourcegra.DrawLine(whitePen, 0, 0, 0, bitmap.Height);
            sourcegra.DrawLine(whitePen, 0, bitmap.Height - 1, bitmap.Width, bitmap.Height - 1);
            sourcegra.DrawLine(whitePen, bitmap.Width - 1, 0, bitmap.Width - 1, bitmap.Height);

            Image myImage = Properties.Resources.triangle;
            TextureBrush myTextureBrush = new TextureBrush(myImage);
            sourcegra.FillRectangle(myTextureBrush, 8, 8, resX-16, resY - 16);

            return bitmap;
        }

        public Bitmap createFlickerImage()
        {
            Bitmap bitmap = new Bitmap(resX, resY);
            Pen whitePen = new Pen(Color.White, 1);
            var sourcegra = Graphics.FromImage(bitmap);//存入画布

            for (int x = 0; x < bitmap.Width; x += 100)
            {
                sourcegra.DrawLine(whitePen, x, 0, x, 20);
                if (x != 0)
                    sourcegra.DrawString(x.ToString(), new Font("宋体", 16, FontStyle.Regular), new SolidBrush(Color.White), x, 30);
            }

            for (int x = 0; x < bitmap.Width; x += 10)
            {
                sourcegra.DrawLine(whitePen, x, 0, x, 10);
            }

            for (int y = 0; y < bitmap.Height; y += 100)
            {
                sourcegra.DrawLine(whitePen, 0, y, 20, y);
                if (y != 0)
                    sourcegra.DrawString(y.ToString(), new Font("宋体", 16, FontStyle.Regular), new SolidBrush(Color.White), 30, y);
            }

            for (int y = 0; y < bitmap.Height; y += 10)
            {
                sourcegra.DrawLine(whitePen, 0, y, 10, y);
            }

            return bitmap;
        }

        public Bitmap createChessImage()
        {
            Bitmap bitmap = new Bitmap(resX, resY);
            Pen whitePen = new Pen(Color.White, 1);
            var sourcegra = Graphics.FromImage(bitmap);//存入画布

            for (int x = 0; x < bitmap.Width; x += 100)
            {
                sourcegra.DrawLine(whitePen, x, 0, x, 20);
                if (x != 0)
                    sourcegra.DrawString(x.ToString(), new Font("宋体", 16, FontStyle.Regular), new SolidBrush(Color.White), x, 30);
            }

            for (int x = 0; x < bitmap.Width; x += 10)
            {
                sourcegra.DrawLine(whitePen, x, 0, x, 10);
            }

            for (int y = 0; y < bitmap.Height; y += 100)
            {
                sourcegra.DrawLine(whitePen, 0, y, 20, y);
                if (y != 0)
                    sourcegra.DrawString(y.ToString(), new Font("宋体", 16, FontStyle.Regular), new SolidBrush(Color.White), 30, y);
            }

            for (int y = 0; y < bitmap.Height; y += 10)
            {
                sourcegra.DrawLine(whitePen, 0, y, 10, y);
            }

            return bitmap;
        }
    }
}
